// 更好
function myInstanceOf(left,right) {

    if(left === null) {
        return false;
    }
    const type = (typeof left);
    if(type !== 'object' && left !== null && type !== 'function') {
        return false;
    }
    
    let proto = Object.getPrototypeOf(left);

    while(proto) {

        if(proto === right.prototype){
            return true;
        }
        proto = Object.getPrototypeOf(proto);
    }
    return false;
}

console.log(myInstanceOf('刘大侠',Object),'刘大侠' instanceof Object);
console.log(myInstanceOf({},Object),{} instanceof Object);
console.log(myInstanceOf([],Object),[] instanceof Object);
console.log(myInstanceOf(new Date(),Date),(new Date) instanceof Date);
console.log(myInstanceOf(null,Object),null instanceof Object);